<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:ui="http://java.sun.com/jsf/facelets">
    <head>
        <title>Admininistrative controls</title>
    </head>
    <body>
        <h:form>
            <h:commandButton value="Logout" action="#{customerManager.logout}"/>
            <h:commandButton value="List gnome types" action="#{gnomeManager.listGnomeTypes}"/>
            <h:commandButton value="List inventory" action="#{gnomeManager.listInventory()}"/>
            <h:commandButton value="List users" action="#{customerManager.listCustomers()}"/>
        </h:form>
        <hr/>
        <h3>Create a Gnome Type</h3>
        <hr/>
            <p>
                <h:form>
                    <h:outputLabel for="type_name" value="Type: "/>
                    <h:inputText id="type_name" value="#{gnomeManager.gnomeTypeName}"/>
                    <h:outputLabel for="type_price" value="Price: "/>
                    <h:inputText id="type_price" value="#{gnomeManager.gnomeTypePrice}"/>
                    <h:commandButton value="Create" action="#{gnomeManager.createGnomeType}"/>
                </h:form>
            </p>
        <hr/>
        <h3>Create a gnome with a given type</h3>
        <hr/>
           <h:form>
                <ui:repeat value="#{gnomeManager.gnomeTypes}" var="gnomeType">
                    <li> 
                        <b>Type:</b> <h:outputText value="#{gnomeType.type}" /> 
                        <b>Price:</b> <h:outputText value="#{gnomeType.price}" /> 
                        <h:commandButton value="Create" action="#{gnomeManager.createGnomeWithType(gnomeType)}"/>
                    </li> 
                </ui:repeat>
            </h:form>
        <hr/>
        <h3>Kill a gnome</h3>
        <hr/>
           <h:form>
                <ui:repeat value="#{gnomeManager.inventory}" var="gnome">
                    <li> 
                        <b>Type:</b> <h:outputText value="#{gnome.type.type}" /> 
                        <b>Price:</b> <h:outputText value="#{gnome.type.price}" />
                        <h:commandButton value="Kill" action="#{gnomeManager.deleteGnome(gnome)}"/>
                    </li> 
                </ui:repeat>
            </h:form>
        <hr/>
        <h3>Modify user status</h3>
        <hr/>
           <h:form>
               <ui:repeat value="#{customerManager.customers}" var="customer">
                    <li> 
                        <b>ID:</b> <h:outputText value="#{customer.id}" />
                        <b>Name:</b> <h:outputText value="#{customer.name}" /> 
                        <b>Password:</b> <h:outputText value="#{customer.password}" />
                        <b>Logged in:</b> <h:outputText value="#{customer.loggedIn}" />
                        <b>Banned:</b> <h:outputText value="#{customer.banned}" />
                        <h:commandButton value="Ban" action="#{customerManager.ban(customer)}"/>
                        <h:commandButton value="Unban" action="#{customerManager.unban(customer)}"/>
                    </li> 
                </ui:repeat>
            </h:form>
        <hr/>
    </body>
</html>
